﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using PotentialRentals.Models;

namespace PotentialRentals.DAL
{
    public class RentalInitializer : DropCreateDatabaseIfModelChanges<RentalDBContext>
    {
        protected override void Seed(RentalDBContext context)
        {
            base.Seed(context);

            var states = new List<State>
            {
                new State { Name = "Alabama", Abbr = "AL" },
                new State { Name = "Alaska", Abbr = "AK" },
                new State { Name = "Arizona", Abbr = "AZ" },
                new State { Name = "Arkansas", Abbr = "AR" },
                new State { Name = "California", Abbr = "CA" },
                new State { Name = "Colorado", Abbr = "CO" },
                new State { Name = "Connecticut", Abbr = "CT" },
                new State { Name = "Delaware", Abbr = "DE" },
                new State { Name = "District of Columbia", Abbr = "DC" },
                new State { Name = "Florida", Abbr = "FL" },
                new State { Name = "Georgia", Abbr = "GA" },
                new State { Name = "Hawaii", Abbr = "HI" },
                new State { Name = "Idaho", Abbr = "ID" },
                new State { Name = "Illinois", Abbr = "IL" },
                new State { Name = "Indiana", Abbr = "IN" },
                new State { Name = "Iowa", Abbr = "IA" },
                new State { Name = "Kansas", Abbr = "KS" },
                new State { Name = "Kentucky", Abbr = "KY" },
                new State { Name = "Louisiana", Abbr = "LA" },
                new State { Name = "Maine", Abbr = "ME" },
                new State { Name = "Maryland", Abbr = "MD" },
                new State { Name = "Massachusetts", Abbr = "MA" },
                new State { Name = "Michigan", Abbr = "MI" },
                new State { Name = "Minnesota", Abbr = "MN" },
                new State { Name = "Mississippi", Abbr = "MS" },
                new State { Name = "Missouri", Abbr = "MO" },
                new State { Name = "Montana", Abbr = "MT" },
                new State { Name = "Nebraska", Abbr = "NE" },
                new State { Name = "Nevada", Abbr = "NV" },
                new State { Name = "New Hampshire", Abbr = "NH" },
                new State { Name = "New Jersey", Abbr = "NJ" },
                new State { Name = "New Mexico", Abbr = "NM" },
                new State { Name = "New York", Abbr = "NY" },
                new State { Name = "North Carolina", Abbr = "NC" },
                new State { Name = "North Dakota", Abbr = "ND" },
                new State { Name = "Ohio", Abbr = "OH" },
                new State { Name = "Oklahoma", Abbr = "OK" },
                new State { Name = "Oregon", Abbr = "OR" },
                new State { Name = "Pennsylvania", Abbr = "PA" },
                new State { Name = "Rhode Island", Abbr = "RI" },
                new State { Name = "South Carolina", Abbr = "SC" },
                new State { Name = "South Dakota", Abbr = "SD" },
                new State { Name = "Tennessee", Abbr = "TN" },
                new State { Name = "Texas", Abbr = "TX" },
                new State { Name = "Utah", Abbr = "UT" },
                new State { Name = "Vermont", Abbr = "VT" },
                new State { Name = "Virginia", Abbr = "VA" },
                new State { Name = "Washington", Abbr = "WA" },
                new State { Name = "West Virginia", Abbr = "WV" },
                new State { Name = "Wisconsin", Abbr = "WI" },
                new State { Name = "Wyoming", Abbr = "WY" }
            };
            states.ForEach(x => context.States.Add(x));
            context.SaveChanges();

            var rentTypes = new List<RentType> {
                new RentType { Name = "Apartment", Description = "Apartment" },
                new RentType { Name = "House", Description = "House" },
                new RentType { Name = "Duplex", Description = "Duplex" },
            };
            rentTypes.ForEach(x => context.RentTypes.Add(x));
            context.SaveChanges();

            var addressAmenities = new List<AddressAmenity> {
                new AddressAmenity { Name = "Clubhouse", Description = "Clubhouse" },
                new AddressAmenity { Name = "Controlled Access", Description = "Controlled Access" },
                new AddressAmenity { Name = "Fitness Center", Description = "Fitness Center" },
                new AddressAmenity { Name = "Garages", Description = "Garages" },
                new AddressAmenity { Name = "Laundry Facilities", Description = "Laundry Facilities" },
                new AddressAmenity { Name = "Off-Street Parking", Description = "Off-Street Parking" },
                new AddressAmenity { Name = "Pool", Description = "Pool" },
                new AddressAmenity { Name = "Playground", Description = "Playground" }
            };
            addressAmenities.ForEach(x => context.AddressAmenities.Add(x));
            context.SaveChanges();

            var rentalAmenities = new List<RentalAmenity> {
                new RentalAmenity { Name = "Laundry", Description = "Laundry" },
                new RentalAmenity { Name = "Washer/Dryer Hookups", Description = "Washer/Dryer Hookups" },
                new RentalAmenity { Name = "Dishwasher", Description = "Dishwasher" },
                new RentalAmenity { Name = "Microwave", Description = "Microwave" },
                new RentalAmenity { Name = "Refrigerator", Description = "Refrigerator" },
                new RentalAmenity { Name = "Stove", Description = "Stove" },
                new RentalAmenity { Name = "Loft", Description = "Loft" },
                new RentalAmenity { Name = "Lawn Care", Description = "including snow" },
                new RentalAmenity { Name = "Trash Paid", Description = "by Landlord" },
                new RentalAmenity { Name = "Heat Paid", Description = "by Landlord" },
                new RentalAmenity { Name = "Electric Paid", Description = "by Landlord" },
                new RentalAmenity { Name = "Water Paid", Description = "by Landlord" },
                new RentalAmenity { Name = "Cable TV Paid", Description = "by Landlord" }
            };
            rentalAmenities.ForEach(x => context.RentalAmenities.Add(x));
            context.SaveChanges();

            /*
            var user = new User() { UserName = "brodkil" };
            context.Users.Add(user);
            context.SaveChanges();

            var address = new Address()
            {
                Street = "1234 S. St.",
                City = "Lincoln",
                State = new State() { StateId = 28 },
                Zip = 68512,
                Lat = 40,
                Lng = -96,
            };
            context.Addresses.Add(address);
            context.SaveChanges();

            var rental = new Rental()
            {
                Address = new Address() { AddressId = 1 },
                Rent = 500,
                Bedrooms = 1,
                Bathrooms = 1.5
            };
            context.Rentals.Add(rental);
            context.SaveChanges();
            */
        }
    }
}